package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;

@SuppressWarnings("serial")
public class GameButton extends JButton{

	private boolean levelSelected;
	/**
	 * Simple game Button, no transparency
	 * @param text
	 */
	public GameButton(String text){
		super(text);
	}
	
	/**
	 * To set button text, button icon, and rollover icon
	 * @param text
	 * @param icon
	 * @param rollIcon
	 */
	public GameButton(String text, ImageIcon icon, ImageIcon rollIcon){
		this.setText(text);
		this.setIcon(icon);
		this.setRolloverIcon(rollIcon);
		
		setUpButton();
	}
	
	public GameButton(ImageIcon icon, ImageIcon rollIcon){
		this.setIcon(icon);
		this.setRolloverIcon(rollIcon);
		
		setUpButton();
	}
	
	/**
	 * Set button up for transparency
	 */
	public void setUpButton(){
		this.setFocusPainted(false);
		this.setOpaque(false);
		this.setContentAreaFilled(false);
		this.setBorderPainted(false);
		this.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
	}

	@Override
	public void setText(String text){
		super.setText(text);
		this.setHorizontalTextPosition(JButton.CENTER);
		this.setVerticalTextPosition(JButton.CENTER);
		this.setFont(new Font("Stencil", Font.PLAIN, 12));
		this.setForeground(new Color(255,255,255, 200));
	}
	
	/**
	 * Return if the level is selected
	 * @return - returns true if the level is selected, false if not. 
	 */
	public boolean levelSelected(){
		return levelSelected;
	} 
	
	public void setLevelSelected(boolean bool){
		levelSelected = bool;
	}
	
	public void setMenuButton(){
		this.setSize(new Dimension(300, 50));
	}
	
	public void setListener(ActionListener al){
		this.addActionListener(al);
	}
	
	public void setTransparentBackground(){
		this.setFocusPainted(false);
		this.setOpaque(false);
		this.setContentAreaFilled(false);
		this.setBorderPainted(false);
	}
}
